package com.yike.user.controller;

import com.yike.common.api.ApiResult;
import com.yike.common.base.BaseController;
import com.yike.common.log.Module;
import com.yike.common.pagination.Paging;
import com.yike.user.param.*;
import com.yike.user.service.PlatformDataService;
import com.yike.user.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 平台数据管理
 *
 * @author Sakura
 * @since 2024-10-18
 */
@Slf4j
@RestController
@RequestMapping("/platform/data")
@Module("user")
@Api(value = "平台数据管理API", tags = {"平台数据管理"})
public class PlatformDataController extends BaseController {

    @Autowired
    private PlatformDataService platformDataService;

    @PostMapping("/getSearchList")
    //@OperationLog(name = "搜索列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "搜索列表", response = SearchListVo.class)
    public ApiResult<Paging<SearchListVo>> getSearchList(@Validated @RequestBody SearchPageParam searchPageParam) throws Exception {
        Paging<SearchListVo> paging = platformDataService.getSearchList(searchPageParam);
        return ApiResult.ok(paging);
    }

    @PostMapping("/getPlatformData")
    @ApiOperation(value = "平台数据总览", response = PlatformDataVo.class)
    public ApiResult<PlatformDataVo> getPlatformData(@Validated @RequestBody PlatformDataParam platformDataParam) throws Exception {
        PlatformDataVo platformDataVo = platformDataService.getPlatformData(platformDataParam);
        return ApiResult.ok(platformDataVo);
    }

    @PostMapping("/getSalesActualCount")
    @ApiOperation(value = "销售实收统计", response = SalesActualCountVo.class)
    public ApiResult<List<SalesActualCountVo>> getSalesActualCount(@Validated @RequestBody SalesActualCountParam salesActualCountParam) throws Exception {
        List<SalesActualCountVo> salesActualCountVos = platformDataService.getSalesActualCount(salesActualCountParam);
        return ApiResult.ok(salesActualCountVos);
    }

    @PostMapping("/getPayTypeData")
    @ApiOperation(value = "支付方式", response = PayTypeDataVo.class)
    public ApiResult<List<PayTypeDataVo>> getPayTypeData(@Validated @RequestBody PayTypeDataParam payTypeDataParam) throws Exception {
        List<PayTypeDataVo> payTypeDataVos = platformDataService.getPayTypeData(payTypeDataParam);
        return ApiResult.ok(payTypeDataVos);
    }

    @PostMapping("/getCategorySalesData")
    @ApiOperation(value = "分类销售", response = CategorySalesDataVo.class)
    public ApiResult<List<CategorySalesDataVo>> getCategorySalesData(@Validated @RequestBody CategoryDataParam categoryDataParam) throws Exception {
        List<CategorySalesDataVo> categorySalesDataVos = platformDataService.getCategorySalesData(categoryDataParam);
        return ApiResult.ok(categorySalesDataVos);
    }

}

